package xyz.lovegu.server.sys.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.lovegu.server.sys.common.DataGridView;
import xyz.lovegu.server.sys.common.ResultMessage;
import xyz.lovegu.server.sys.common.ResultObj;
import xyz.lovegu.server.sys.common.ResultUtil;
import xyz.lovegu.server.sys.service.NoticeService;
import xyz.lovegu.server.sys.vos.NoticeVo;

/**
 * @author 老顾
 * @title: NoticeController
 * @projectName campus-prevention-system
 * @email: 1437594522@qq.com
 * @date 2022/5/8 23:27
 */
@Validated
@RestController
@RequestMapping("sys/notice")
@RequiredArgsConstructor
public class NoticeController {

    private final NoticeService noticeService;

    @PostMapping("addNotice")
    public ResultMessage<ResultObj> addNotice(@RequestBody NoticeVo noticeVo) {
        return ResultUtil.data(noticeService.addNotice(noticeVo));
    }

    @PostMapping("deleteNoticeById")
    public ResultMessage<ResultObj> deleteNoticeById(@RequestBody NoticeVo noticeVo) {
        return ResultUtil.data(noticeService.deleteNoticeById(noticeVo));
    }

    @PostMapping("deleteBatchNoticeByIds")
    public ResultMessage<ResultObj> deleteBatchNoticeByIds(@RequestBody NoticeVo noticeVo) {
        return ResultUtil.data(noticeService.deleteBatchNoticeByIds(noticeVo));
    }

    @PostMapping("updateNotice")
    public ResultMessage<ResultObj> updateNotice(@RequestBody NoticeVo noticeVo) {
        return ResultUtil.data(noticeService.updateNotice(noticeVo));
    }

    @GetMapping("getNoticeById")
    public ResultMessage<Object> getNoticeById(@RequestParam("id") Integer id) {
        return ResultUtil.data(noticeService.getNoticeById(id));
    }

    @GetMapping("getAllNotices")
    public ResultMessage<Object> getAllNotices(NoticeVo noticeVo) {
        return ResultUtil.data(noticeService.getAllNotices(noticeVo));
    }
}
